speaker2 2.2.1
Loading...
Searching...
No Matches
speaker2.h File Reference

This file contains API for Speaker 2 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_spi_master.h"
#include "spi_specifics.h"

Go to the source code of this file.

Data Structures

struct  speaker2_device_id_t
 Speaker 2 Click device ID object. More...
struct  speaker2_t
 Speaker 2 Click context object. More...
struct  speaker2_cfg_t
 Speaker 2 Click configuration object. More...

Macros

#define SPEAKER2_CMD_PLAY_VP   0xA6
 Speaker 2 commands list.
#define SPEAKER2_CMD_PLAY_VP_RN   0xAE
#define SPEAKER2_CMD_PLAY_VP_LP   0xA4
#define SPEAKER2_CMD_PLAY_VP_RN_LP   0xB2
#define SPEAKER2_CMD_EXE_VM   0xB0
#define SPEAKER2_CMD_EXE_VM_RN   0xBC
#define SPEAKER2_CMD_PLAY_SIL   0xA8
#define SPEAKER2_CMD_STOP   0x2A
#define SPEAKER2_CMD_STOP_LP   0x2E
#define SPEAKER2_CMD_SPI_PCM_READ   0xAC
#define SPEAKER2_CMD_SPI_SND_DEC   0xC0
#define SPEAKER2_CMD_READ_STATUS   0x40
#define SPEAKER2_CMD_READ_INT   0x46
#define SPEAKER2_CMD_READ_ID   0x48
#define SPEAKER2_CMD_DIG_READ   0xA2
#define SPEAKER2_CMD_DIG_WRITE   0xA0
#define SPEAKER2_CMD_ERASE_MEM   0x24
#define SPEAKER2_CMD_CHIP_ERASE   0x26
#define SPEAKER2_CMD_CHECKSUM   0xF2
#define SPEAKER2_CMD_PWR_UP   0x10
#define SPEAKER2_CMD_PWR_DN   0x12
#define SPEAKER2_CMD_SET_CLK_CFG   0xB4
#define SPEAKER2_CMD_RD_CLK_CFG   0xB6
#define SPEAKER2_CMD_WR_CFG_REG   0xB8
#define SPEAKER2_CMD_RD_CFG_REG   0xBA
#define SPEAKER2_CMD_RESET   0x14
#define SPEAKER2_REG_SAMPLE_RATE_OVERWRITE   0x00
 Speaker 2 registers list.
#define SPEAKER2_REG_DECOMPRESSION_CONTROL   0x01
#define SPEAKER2_REG_PATH_CONTROL   0x02
#define SPEAKER2_REG_VOLUME_CONTROL   0x03
#define SPEAKER2_REG_CHECKSUM_RESET   0x04
#define SPEAKER2_REG_THERMAL_CONTROL   0x05
#define SPEAKER2_REG_MASK_JUMP_CONTROL   0x08
#define SPEAKER2_REG_PWM_CONTROL   0x09
#define SPEAKER2_REG_CH_CONTROL   0x0C
#define SPEAKER2_REG_CH0_COUNTER_CONTROL   0x0D
#define SPEAKER2_REG_CH1_COUNTER_CONTROL   0x0E
#define SPEAKER2_REG_CH2_COUNTER_CONTROL   0x0F
#define SPEAKER2_REG_CHECKSUM_1_LB   0x10
#define SPEAKER2_REG_CHECKSUM_1_HB   0x11
#define SPEAKER2_REG_CHECKSUM_2_LB   0x12
#define SPEAKER2_REG_CHECKSUM_2_HB   0x13
#define SPEAKER2_REG_GPIO_TRIGGER_CH_SEL_1   0x14
#define SPEAKER2_REG_GPIO_TRIGGER_CH_SEL_2   0x15
#define SPEAKER2_REG_TRIGGER_VOLUME_CONTROL   0x16
#define SPEAKER2_REG_DEBOUNCE_TIME_CONTROL   0x17
#define SPEAKER2_REG_OUTPUT_DATA_CONTROL   0x19
#define SPEAKER2_REG_OUTPUT_ENABLE_CONTROL   0x1A
#define SPEAKER2_REG_PULL_ENABLE_CONTROL   0x1B
#define SPEAKER2_REG_INPUT_DATA_CONTROL   0x1C
#define SPEAKER2_REG_PULL_SELECT_CONTROL   0x1D
#define SPEAKER2_REG_ALT_FUNCTION_CONTROL_1   0x1E
#define SPEAKER2_REG_ALT_FUNCTION_CONTROL_0   0x1F
#define SPEAKER2_REG_R0_L   0x20
#define SPEAKER2_REG_R0_H   0x21
#define SPEAKER2_REG_R1_L   0x22
#define SPEAKER2_REG_R1_H   0x23
#define SPEAKER2_REG_R2_L   0x24
#define SPEAKER2_REG_R2_H   0x25
#define SPEAKER2_REG_R3_L   0x26
#define SPEAKER2_REG_R3_H   0x27
#define SPEAKER2_REG_R4_L   0x28
#define SPEAKER2_REG_R4_H   0x29
#define SPEAKER2_REG_R5_L   0x2A
#define SPEAKER2_REG_R5_H   0x2B
#define SPEAKER2_REG_R6_L   0x2C
#define SPEAKER2_REG_R6_H   0x2D
#define SPEAKER2_REG_R7_L   0x2E
#define SPEAKER2_REG_R7_H   0x2F
#define SPEAKER2_STATUS_PD   0x80
 Speaker 2 device status setting.
#define SPEAKER2_STATUS_DBUF_RDY   0x40
#define SPEAKER2_STATUS_INT   0x20
#define SPEAKER2_STATUS_CH2_BSY   0x08
#define SPEAKER2_STATUS_CH1_BSY   0x04
#define SPEAKER2_STATUS_CH0_BSY   0x02
#define SPEAKER2_STATUS_DIG_BSY   0x01
#define SPEAKER2_STATUS_CLEAR   0x00
#define SPEAKER2_INT_STATUS_TALARM_INT   0x80
 Speaker 2 interrupt status setting.
#define SPEAKER2_INT_STATUS_MPT_ERR   0x40
#define SPEAKER2_INT_STATUS_WR_FIN   0x20
#define SPEAKER2_INT_STATUS_CMD_ERR   0x10
#define SPEAKER2_INT_STATUS_OVF_ERR   0x08
#define SPEAKER2_INT_STATUS_CH2_FIN   0x04
#define SPEAKER2_INT_STATUS_CH1_FIN   0x02
#define SPEAKER2_INT_STATUS_CH0_FIN   0x01
#define SPEAKER2_DEVICE_ID_PART   0x05
 Speaker 2 device ID setting.
#define SPEAKER2_DEVICE_ID_MAN   0xEF
#define SPEAKER2_DEVICE_ID_MEM_TYPE   0x20
#define SPEAKER2_DEVICE_ID_DEV   0x60
#define SPEAKER2_GPIO_AF1_IO   0
 Speaker 2 GPIO alternate function setting.
#define SPEAKER2_GPIO_AF1_AF   0
#define SPEAKER2_GPIO_AF1_FT   1
#define SPEAKER2_GPIO_AF1_RFT   1
#define SPEAKER2_GPIO_AF0_IO   0
#define SPEAKER2_GPIO_AF0_AF   1
#define SPEAKER2_GPIO_AF0_FT   0
#define SPEAKER2_GPIO_AF0_RFT   1
#define SPEAKER2_GPIO_0_POS   0
#define SPEAKER2_GPIO_1_POS   1
#define SPEAKER2_GPIO_2_POS   2
#define SPEAKER2_GPIO_3_POS   3
#define SPEAKER2_GPIO_4_POS   4
#define SPEAKER2_GPIO_5_POS   5
#define SPEAKER2_VM0_POI   0
 Speaker 2 Voice Macros and Voice Prompts setting.
#define SPEAKER2_VM1_PU   1
#define SPEAKER2_VM2_WAKEUP   2
#define SPEAKER2_VM3_ONE   3
#define SPEAKER2_VM4_TWO   4
#define SPEAKER2_VM5_THREE   5
#define SPEAKER2_VM6_FOUR   6
#define SPEAKER2_VM7_FIVE   7
#define SPEAKER2_VM8_SIX   8
#define SPEAKER2_VP9_ONE   9
#define SPEAKER2_VP10_TWO   10
#define SPEAKER2_VP11_THREE   11
#define SPEAKER2_VP12_FOUR   12
#define SPEAKER2_VP13_FIVE   13
#define SPEAKER2_VP14_SIX   14
#define SPEAKER2_VP15_FAST_BEEP   15
#define SPEAKER2_FLASH_START   0x000000ul
 Speaker 2 flash size setting.
#define SPEAKER2_FLASH_END   0x03FFFFul
#define SPEAKER2_PAYLOAD_SIZE   256
 Speaker 2 cmd payload size setting.
#define SPEAKER2_TIMEOUT_10S   10000
 Speaker 2 timeout setting.
#define SPEAKER2_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
#define SPEAKER2_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
#define SPEAKER2_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.

Enumerations

enum  speaker2_return_value_t { SPEAKER2_OK = 0 , SPEAKER2_ERROR = -1 }
 Speaker 2 Click return value data. More...

Functions

void speaker2_cfg_setup (speaker2_cfg_t *cfg)
 Speaker 2 configuration object setup function.
err_t speaker2_init (speaker2_t *ctx, speaker2_cfg_t *cfg)
 Speaker 2 initialization function.
err_t speaker2_default_cfg (speaker2_t *ctx)
 Speaker 2 default configuration function.
err_t speaker2_send_command (speaker2_t *ctx, uint8_t cmd, uint8_t *payload, uint16_t payload_len)
 Speaker 2 send command function.
void speaker2_set_io5_pin (speaker2_t *ctx, uint8_t state)
 Speaker 2 set IO5 pin function.
uint8_t speaker2_get_rdy_pin (speaker2_t *ctx)
 Speaker 2 get RDY pin function.
uint8_t speaker2_get_int_pin (speaker2_t *ctx)
 Speaker 2 get INT pin function.
err_t speaker2_wait_ready (speaker2_t *ctx)
 Speaker 2 wait ready function.
err_t speaker2_wait_status (speaker2_t *ctx, uint8_t mask, uint8_t state)
 Speaker 2 wait status function.
err_t speaker2_wait_idle (speaker2_t *ctx)
 Speaker 2 wait idle function.
err_t speaker2_check_communication (speaker2_t *ctx)
 Speaker 2 check communication function.
err_t speaker2_read_status (speaker2_t *ctx, uint8_t *int_status)
 Speaker 2 read status function.
err_t speaker2_clear_interrupt (speaker2_t *ctx, uint8_t *int_status)
 Speaker 2 clear interrupt function.
err_t speaker2_read_device_id (speaker2_t *ctx, speaker2_device_id_t *device_id)
 Speaker 2 read device ID function.
err_t speaker2_power_up (speaker2_t *ctx)
 Speaker 2 power up function.
err_t speaker2_power_down (speaker2_t *ctx)
 Speaker 2 power down function.
err_t speaker2_reset_device (speaker2_t *ctx)
 Speaker 2 reset device function.
err_t speaker2_memory_erase (speaker2_t *ctx, uint32_t address)
 Speaker 2 memory erase function.
err_t speaker2_chip_erase (speaker2_t *ctx)
 Speaker 2 chip erase function.
err_t speaker2_flash_write (speaker2_t *ctx, uint32_t address, uint8_t *data_in, uint16_t data_len)
 Speaker 2 flash write function.
err_t speaker2_flash_read (speaker2_t *ctx, uint32_t address, uint8_t *data_out, uint16_t data_len)
 Speaker 2 flash read function.
err_t speaker2_write_binary (speaker2_t *ctx, uint32_t address, const uint8_t *data_in, uint16_t data_len)
 Speaker 2 write binary function.
err_t speaker2_write_cfg_reg (speaker2_t *ctx, uint8_t reg, uint8_t data_in)
 Speaker 2 write configuration register function.
err_t speaker2_read_cfg_reg (speaker2_t *ctx, uint8_t reg, uint8_t *data_out)
 Speaker 2 read configuration register function.
err_t speaker2_set_clock_cfg (speaker2_t *ctx, uint8_t clk_cfg)
 Speaker 2 set clock configuration function.
err_t speaker2_read_clock_cfg (speaker2_t *ctx, uint8_t *clk_cfg)
 Speaker 2 read clock configuration function.
err_t speaker2_spi_audio_write (speaker2_t *ctx, uint8_t *data_in, uint16_t data_len)
 Speaker 2 SPI audio write function.
err_t speaker2_pcm_audio_read (speaker2_t *ctx, uint16_t *data_out, uint16_t data_len)
 Speaker 2 PCM audio read function.
err_t speaker2_play_voice (speaker2_t *ctx, uint16_t index)
 Speaker 2 play voice function.
err_t speaker2_play_voice_loop (speaker2_t *ctx, uint16_t index, uint16_t loop_cnt)
 Speaker 2 play voice loop function.
err_t speaker2_play_macro (speaker2_t *ctx, uint16_t index)
 Speaker 2 play macro function.
err_t speaker2_play_silence (speaker2_t *ctx, uint8_t len)
 Speaker 2 play silence function.
err_t speaker2_stop_play (speaker2_t *ctx)
 Speaker 2 stop play function.
err_t speaker2_stop_loop_play (speaker2_t *ctx)
 Speaker 2 stop loop play function.

Detailed Description

This file contains API for Speaker 2 Click Driver.

Enumeration Type Documentation

◆ speaker2_return_value_t

Speaker 2 Click return value data.

Predefined enum values for driver return values.

Enumerator
SPEAKER2_OK 
SPEAKER2_ERROR